<html>
<head><meta charset="utf-8"><title>target cfg in Cargo.toml · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html">target cfg in Cargo.toml</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210577204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210577204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210577204">(Sep 18 2020 at 21:25)</a>:</h4>
<p>Hi, is <code>[target.'cfg(feature = "feature")'.dependencies]</code> something that would work in <code>Cargo.toml</code>?</p>
<p>I'm trying to work around issues with <code>[target.'cfg(target_arch = "wasm32")'.dependencies]</code> by using <code>[target.'cfg(feature = "wasm_bindgen")'.dependencies]</code> instead, if possible.</p>



<a name="210577454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210577454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210577454">(Sep 18 2020 at 21:28)</a>:</h4>
<p>I believe that i have tried that before and it has not properly worked with feature based conditional dependency selection.</p>



<a name="210577893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210577893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210577893">(Sep 18 2020 at 21:32)</a>:</h4>
<p>Cargo features cannot be specified in the <code>[target]</code> table. The dependency should be marked as <code>optional</code>, and then listed in the <code>[features]</code> table.   What issues are you having with <code>target_arch = "wasm32"</code>?</p>



<a name="210601441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210601441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210601441">(Sep 19 2020 at 07:06)</a>:</h4>
<p><span class="user-mention" data-user-id="120518">@Eric Huss</span> I'm curious if there's any <em>fundamental</em> reason we couldn't support arbitrary cfg there.</p>



<a name="210620319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210620319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210620319">(Sep 19 2020 at 15:22)</a>:</h4>
<p>Weird thought, maybe we just do away with <code>optional</code> dependencies and their entanglement with feature names. And just use <code>'cfg(feature = "feature")'</code> syntax for when a feature adds a dependency.</p>



<a name="210620456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210620456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210620456">(Sep 19 2020 at 15:26)</a>:</h4>
<blockquote>
<p>any <em>fundamental</em> reason</p>
</blockquote>
<p>We would need to deal with<code> 'cfg(not(feature = "feature"))'</code>, witch brakes "features are additive."</p>



<a name="210620462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210620462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210620462">(Sep 19 2020 at 15:26)</a>:</h4>
<p>you could just ... not parse that, though it'd be ungreat</p>



<a name="210624248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210624248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210624248">(Sep 19 2020 at 16:52)</a>:</h4>
<p>I think supporting features in <code>[target]</code> is possible in the new feature resolver (though not easy).  I'm slightly concerned about having two ways to do the same thing, but I can see how the inconsistency from Rust code can be unintuitive.</p>



<a name="210625329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/target%20cfg%20in%20Cargo.toml/near/210625329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/target.20cfg.20in.20Cargo.2Etoml.html#210625329">(Sep 19 2020 at 17:19)</a>:</h4>
<p><span class="user-mention" data-user-id="120179">@Eh2406</span> If the resolver can deal with it, I hope we do one day change "features are additive". There are useful reasons to have mutually exclusive features, or features that replace one package with another.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>